<?php
namespace app\app\controller\v1;
use Think\Controller;
use think\Db;
use think\Request;
use app\app\util\OnlineUtils;
class RoleController extends BaseController{


    /**
     * @return array
     * 根据用户性别展示人物
     */
    public function showRole()
    {
        $user_id  = OnlineUtils::getUserIdBySid();
        $userInfo = Db::name('user')->find($user_id);
        if( $userInfo ){
            //gender  1 男  2  女  0  未知;性别未知默认为男性角色
            if( $userInfo['gender'] == 1 || $userInfo['gender'] == 0){
                $role = Db::name('role')->where(['gender'=>1,'status'=>1])->select();
            }elseif ( $userInfo['gender'] == 2 ){
                $role = Db::name('role')->where(['gender'=>2,'status'=>1])->select();
            }
            return ft(200,'success',$role);

        }else{
            return ft(402,'找不到用户信息');
        }

    }
}
